package com.gm.wj.entity;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import lombok.ToString;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;

import javax.persistence.*;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;

/**
 * @program: wj
 * @description: 学生
 * @author: Huang_shengjun
 * @create: 2020-09-16 20:48
 **/
@Data
@Entity
@Table(name = "sys_student")
@ToString
@JsonIgnoreProperties({ "handler","hibernateLazyInitializer" })
// 软删除
@SQLDelete(sql = "update sys_student set is_delete = 1 where id = ?")
@Where( clause = "is_delete = 0" )
public class SysStudent {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private int id;

    @NotEmpty(message = "用户名不能为空")
    private String username;

    private String stuNo;

    @NotEmpty(message = "姓名不能为空")
    private String stuName;

    @NotEmpty(message = "电话不能为空")
    private String phone;

    @NotEmpty(message = "邮箱不能为空")
    @Email(message = "请输入正确的邮箱")
    private String email;

    private String address;

    private String imageUrl;

    private boolean enabled;

    private int sex;

    /**
     * 入学时间
     */
    private String createTime;

    /**
     * 0-未删除，1-已删除
     */
    /**
     * 软删除
     */
    @Column(name="is_delete")
    private int isDelete;
}
